% Solve for the Ramsey problem with HSV tax

temp.ans = fminsearch(@(x) -RamseyHSVObjective(x,pr,w,pai,pw,G),pr.tau);
RamseyHSVObjective(temp.ans,pr,w,pai,pw,G);

load lambda
load tau
load c
load y
r_hsv.lambda  = lambda;
r_hsv.tau     = tau;
r_hsv.c       = c;
r_hsv.y       = y;
r_hsv.output  = sum(pai.*y);
r_hsv.welfare = sum(pw.*pai.*Utility(c,y,w,pr));
r_hsv.MTR     = 1-pr.Om./c.^(-pr.gam).*w.^-(1+pr.sig).*y.^pr.sig;
r_hsv.ATR     = (y-c)./y;
r_hsv.WelfareGain = 100*fzero(@(x) sum(pw.*pai.*Utility((1+x).*baseline.c,baseline.y,w,pr))-r_hsv.welfare,.5);
r_hsv.OutputLoss  = 100*(r_hsv.output/baseline.output-1);
r_hsv.EfAveMTR  = sum(pai.*r_hsv.MTR.*r_hsv.y/r_hsv.output);
[temp.y,temp.i] = min(r_hsv.y);
temp.c          = r_hsv.c(temp.i);
r_hsv.Tr2Y      = (temp.c-temp.y)./r_hsv.output;
r_hsv.TrG2Y     = (temp.c-temp.y+G)./r_hsv.output;

save ./variables/r_hsv r_hsv
delete lambda.mat tau.mat c.mat y.mat